<template>
  <div class="ws"></div>
</template>

<script>
import Websocket from '@/websocket'
import SockJS from 'sockjs-client'
import Stomp from 'stompjs'


export default {
    name: 'Ws',
    data () {
        return {
            client: null
        }
    },
    mounted () {
        this.init()
    },
    methods: {
        init () {
            const sock = new SockJS('http://192.168.96.134:8080/gs-guide-websocket')
            const that = this
            const client = Stomp.over(sock)
            client.connect(
                {},
                (frame) => {
                    client.subscribe('/topic/greetings', (greeting) => {
                        console.log('!greeting: ', JSON.parse(greeting.body).content)
                    })
                },
            )
            this.client = client
        }
        // init () {
        //     const config = {

        //         // socketId: '408755***@qq.com',

        //         // socketTicket: Cookie.getToken(),

        //         socketUrl: 'http://192.168.96.134:8080/gs-guide-websocket', // '//113.88.13.224:9205/bas-ws-endpoint',

        //         subscribeTag: '/topic/greetings',// '/user-ws/' + this.socketId + '/ws/noticeCenter',

        //         sendMsgTag: '/bas-ws-receive/ws/noticeCenterHeartBeat'

        //     }

        //     const ws = new Websocket(config, this.onReceive, this.onSuccess, this.onError)

        //     // init
        //     ws.init()

        //     // close
        //     // ws.stopConnect()

        //     // destroy
        //     // ws.destroyed()
        // },
        // onReceive (msg) {
        //     console.log('msg', msg)
        // },
        // onSuccess (msg) {
        //     console.log(msg, 'success')
        // },
        // onError (err) {
        //     console.log(err, 'err')
        // }
    }
}
</script>